Fixes some small potential crashes when user input is incorrect.