Some formatting fixes
Remove use of old-style globals
Switch from including common file to require