Made methods chainable + small cleanups.

By adding "return this" to the methods they become chainable.
Also made a few small optimizations.