Added more functionality with transactions, refactored some stull too.