Bug fix and Heroku compatibility.
Adding more test classes and comments.