Refactored into a library and a sample project that depends on it.