Fixed some bugs and a segfault

2 jobs for v0.3 in 1 minute and 21 seconds (queued for 3 seconds)