I hear, even our code isn't always consistent. What I try to do, use the OriginalContentId everywhere. For relationships, etc....
Then when querying, use status=live && visible=true && originalcontentid=?
When editing, you query for the master so you use id=? && status=master, check out the master (which creates the temp),make your changes, and then check in the temp, which updates the live.
There's good example in the module builder documentation that's generated for you when you create the module.