Fixes some logic in the handlers