Bugfixing

Fixed a few static variables, and replace some variables.