Fixed issues according to Alexander's comment