New modified version. Implemented Sjurdur's stuff.