Cleaned up code a bit. Bug with clearing.