fix to #44 and cleanup