v0.4.0 and some code cleanup