Fixed some issues based on various comments