Cleaned up code a bit, added support for 0.4.0