Method chaining

In this code I added support for method chaining. I also fixed composer
autoloading and cleaned up and optimized code.