First working version. Euler is buggy though.