numerous improvements and bug fixes, including issues #7 #6 #5