Some error handling, object as states
Remove debugging