Updating as per review comments (changing Double to double, Long to long, logging exceptions correctly etc)