Fixed some functionality problems