EOD 22/9/2013... Added logging and optimized DB actions..