Implemented #43, minor changes and fixes