lua division: refactoring in virgo

This is https://github.com/racker/virgo/pull/444 squashed and rebased onto master. Please see detailed commits in https://github.com/racker/virgo/pull/444

Tested on:
* centos64-x86_64
* win2012-x64
* Mac OS X 10.8.4 (case insensitive FS)