Code cleaning and bug solving

Transformed several function defs to one-liners, and found bug on line 424.