Error fixes & some optimization

- Just some a small fix & some minor optimization