Refactorings & templates & prepared statements

Started using prepared statements for database queries to avoid SQL
injections.
Worked on templates (user module almost complete)
Refactored and extended BL.