Cleanup and final changes!

The init function now takes a struct as input parameter. The function checks
for illegal values returns error code if so. The code passes all tests, both manual
and automated, and the code is cleaned from comments.