Debugging #43
Updated with some fixes for #43
Minor bug fixes