Bugfixes and improvements. Closes #13. Adresses #12 and #9.