Fixes issue #26, bug fixes throughout, and also going to resolve issue #22