refactored for library
refactored for library
minor refactorings
added library template files
V1