Some fixes.
Refactored: names, put some simple functions inline, ...