Style improvements, error check