Added more documentation + fixed some minor bugs.