Fix #47, Fix #23, Fix #20, Fix #38