Fixes for issues #14, #13, #13, #11, #6