Bug-fixes. Code is not documented or organized or generally prettified
yet. Will do that tomorrow.