Add automatic flushing of rewrites
Move flushing to a function

Allows using manually to flush rewrites. This is handy if you want to add
extra features (such as locking) but still use the hooks and better
flushing system.
Merge pull request #13 from humanmade/auto-flush

Add automatic flushing of rewrites