You still have several static variables here. These need to be removed as they will lead to bugs.