Added documentation, removed some of the hackiness.