cleanup and documentation

moved classes into separate files
added comments and documentation
removed closing tags (?>)