Code formatting and several small fixes and improvements all over the
place