Template files and Machine Names
You shouldn't have that 

$node = $variables['node'];


outside your function.

put it as the first line inside your preprocess function.

$variables doesn't actually exist out there (and if it does it won't be the $variables variable you're expecting in this case).