Fix #15, #14 - minor bug fixes and improvements