fixed a bunch of bugs and formatting issues as mentioned in issue 7.