Fix crash, clean up border code