Added button and fixed some bugs.