fixes and speed opt