Clean up code, add clear function