improvements and bug fixes, fixes #3