Cleaned up functions and variable declarations