More refactor.
Changes for Linux compat.
Small changes.
More linux changes and other small stuff.
Enabled preferences again.
Preferences fixes.