Version 0.4.0. Big cleanup reflecting API and lib changes