Form callback

See #8 

Also fixed some problems with race conditions.