Fixes courtesy of @jonfriskics