Fixes #265 and other minor patch