Reorganised code, added crypto + tests