Added some more background documentation, some code clean-up