Lots of fixes and closes #192