Cleaned up comments
finished implementation of all subroutines