Refactored some methods, add docs, etc
Fixed a few bugs