Resolved several bugs