code standardization

fixed small bugs
added possibility to store/use letter templates to/from database