fixed #25 and general improvements