Fixed possible recursion crash and some small fixes.