Fixed #507 completely