Fixed bugs and added a clear button