Organize import
Mostly remove unused import
Make userSession serializable for persistant storage
Remove el-functor usage
Fix generic type safety and raw type.