Added Payment functionality and fixed some bugs.