Some changes to code, + automated tests