Fix bug
Merge pull request #211 from mannol1/master

Fix bug
fix a few formatting bugs and simplify code a bit