Fixed elementary bugs