Refactor to save space
Remove pointless model code
Add error checking