bug fixes

#91, #95, #83