Some improvement and fixes