fix #58
fixing #57
fixed various bugs