Fixes #54 and an handful of other things