fixed some ugly stuff in antoine's code