Update state to a standard format

I was going to work on this but there was  mix of style between use of tabs and spaces as well as many strange indentations. I did my best to figure out @sahusoftcom coding style and apply it to the directive.