Refactored transactions into transaction class and modified logic organi...

...zation slightly