restructure, code cleanup and service implementation

Hi JD,

I have restructured the code and did some cleanups..

I have also implemented the service..

Requesting a pull from you.

Cheers!!
Satish