Add example of rest hook usage, minor fixes and code clean