Reworked settings to make them working. Other minor fixes and rework of the code.