Fixed #38 and implemented #27