Cleaned up some functions