Fixes some bugs

Fixes some bugs. Will merge soonish, I think if I keep pushing my work to ``dev``, leaving it there for hours or a day before merging it to master it gives people a chance to see whats going on and review it if they want.