Restored all original functionality

Code should now basically work both async and sync.