Core cleanup

1. Added documentation to all classes in the **core** package
2. Made **minor** code optimizations

To the outside world, the **core** has not changed.