cleaning up code

move sources to head,
modify indentation