Add transaction validation, refactor, PEP8ize