Ported the code to the new clever syntax and fixed some stuff.