Reindented to 2 spaces, cleaned up code

Change-Id: Ie5e724948c6743a36b74fa7a64c2a35810c94608
Added Apache 2.0 License

Change-Id: I8445c8bf8e401e49a26c5795c74a7d297cafbd83