several fixes and finished template