First working version, without S2K part minified. Requires some cleanup.