Revert "Revert "Applied a few changes""

This reverts commit e171b17445b31f3001474404b653d8935e72e2d0.