Fix race condition
Safety-proof possible undefined accesses
Fix using two smilies next to each other causing broken syntax