Adding back missing code and edits