Made more functions static for safety - fixed const correctness issues