Worked out some bugs