Fixed some bugs and made final adjustments