Properly reset the source filter when a new file is opened.

Previously the old state was not properly cleared up, resulting in
a new set of pins being created and the old ones never being cleaned up.
This caused the graph to no longer function.

Fixes issue 375.
Move common init code to a more appropriate place