Bugfixes and improvements. Close #8. Close #5.