Fixed inconsistent line ends.
Fixed suddenly broken build.
Commented and refactored a bit.