Handle functions returning values

This commit changes when resources are claimed. We now expect all methods defined on an object that returns a value (i.e. not void) to not do any operations that needs the object to be locked. If such operations are needed this must be done in a void function which then will be called with sync or async and lock the object.