Code tidyed a bit