Fixed serveral problems

Fixed #106, #101, #82