Cleaned up misc code