fixes #1 and a lot of stuff