Turns out the code was fine. But, I was using JQuery.ready instead of $(document).ready for my main code. This resulted in the code setting the default visibility values every time the DOM was changed, insted of only the fist time.
Simple and stupid mistakes always take the longest to debug. Cheers! ep