Cleaned up render code a little