Added docs, comments and a little signature refactoring.