Added error handling to loadimage
Refactored UI updates to uiLoop