Refactoring, improved documentation, added demo