Bug fixes. Closes #77 #73 #79 #76