Another pitfall to look out for (one that seems obvious but have seen before) - when passing by reference and also maybe using locals is never return a reference to local data when returning from a function. Of course, the data will be popped off the stack and won't exist any more. Reads will provide "bad" data (i.e. whatever happens to be on that stack location) and writes can really screw things up!!