Revert "Revert "Merge pull request #593 from neojski/583-call-compact-ca...

...llback-when-done""

This reverts commit 4176689b10c5c20ca299ddf71d5c27726b2f1856.