Convert to proper R package
Remove redundant code
Add man page