Minor optimization changes
Much unit testing... wow
Made docstrings all sphinxy
Added test cases for weight calculation