Deleting unused code
Basic optimisations