Custom Editor Window for Prefabs

Since Unity changed the way you edit prefabs in the inspector my custom editor window is not working. The changes I make through my custom window are not saved to the prefab. And if I make a change to the prefab through inspector window, the prefab in my editor window gets lost!
How do I edit my prefabs in the new system with my custom editor window?

Here is my code:

public class WavemachineEditorWindow : EditorWindow
{
    private Wavemachine wavemachine;

    void OnGUI()
    {
        wavemachine = (Wavemachine)EditorGUILayout.ObjectField(wavemachine, typeof(Wavemachine), false, GUILayout.Width(200));

        wavemachine.someValue = EditorGUILayout.IntField("Value:", wavemachine.someValue);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(wavemachine);
        }
    }
}

Hey Guys i have recently started writing on Creating custom Editor Window and going to cover lot of details like: how to create editor window in first place, than different Gui, loading textures, prefab from Resource folder, etc.