Incomplete version of improvements discussed with Iulian (unit tests not working yet)