fixed #19 and fixed #13 (at least mostly)