Organise code and catch bad input and exceptions