Fixed #46, #40, #38