Move tasks into separate header file
Wrap API stuff with try..catch. Lots of copy paste.