Added a new template. Code cleanup. Refactoring and implementations. More documentation added and todos annotated by @todo