minor changes to code formatting
updated code style. moved template definition into separate module.