Fixes and missing logic from original commit