Code cleanup. Added some inline docs in test app. Integrated mailer in testapp.