Updated to v0.4. Includes even more magic. Also moved some common bits to shared functions.