Added comments and divided into implementation and definition.