Added more documentation, stripped out some code