Fixed a lot of wrong coding discovered thanks to modularization