Added some documentation, cleaned things up a bit