Replace dynamic_cast with static_cast in gangliad.  Other minor code cleanup. #3515