Code cleanup; added some missing documentation where needed