Re factored code

Please check the readme file for change log, also check the files in mail attachement