Added some documentation and changed some names to be more consistent.