Added write support, improved consistency in some places and fixed a few bugs (where break's were missing for example).