Remove trailing whitespaces and tabs
Refactor and improve code

Clean code to improve readability, allow to use different TPE in the
same application, add parameters like mail.