Various bug fixes

Just testing what Travis says before merging.