quick fix not freed memory reported in #2 and #3

two small fixes for reported memory freeing problems and a little cosmetics