Replaced a lot of die() with throw(), and general cleanup in WMEditor.php