patched in Nathans refactoring
Merge pull request #7 from nikhilRP/refac

Patched in Nathan's refactoring
Updated bed tools and fixed a memory leak