Added documentation and moved a few functions that got left behind before