Separated some views code, fixed bug with templates