Keep refect, move key function to lib package, move demo code to demo
package