Improvements in security class, also made a method for logging exceptions.