Extracted Exception class and fixed some psr issues