Some code re-arranging and cleanup for speedup
One more speedup and a bug fix
Merge pull request #144 from ehenneken/paper_network_speedup

Some code re-arranging and cleanup for speedup