cleaning up code
modularizing source
fixing null bugs