lots of changes fixes #15, fixes #13