BUG: Fixed various bugs