added option to show header in output. and some more cleaning