Fixed issues commented by Miles