Fixed slightly more complicated bugs