Code cleanup/minor reorg and version bump to 0.5