Fixed #30, #31, #32, improved #10