Code simplification

I put same code in new functions.
Synchronus part modified a little as I find it not working(there was no "$uid/" before $page and so on). Synchronus is the only way for mac as it have no inotify-wait.

I never use Mac and looks like never will :) But I need this to work on it - will try.

And again. Very special thanks for you for your great job.