           | :report_encoder_position_scaled
           | :report_encoder_position_raw
 
-  @spec report_xyz(binary, reporter) :: {binary, {reporter, binary, binary, binary}}
+  @spec report_xyz(binary, reporter)
+    :: {binary, {reporter, binary, binary, binary}}
   defp report_xyz(position, reporter) when is_bitstring(position),
     do: position |> String.split(" ") |> do_parse_pos(reporter)
 
+  @valid_position_reporters [
+    :report_current_position,
+    :report_encoder_position_scaled
+  ]
   defp do_parse_pos(["X" <> x, "Y" <> y, "Z" <> z, "Q" <> tag], reporter)
-       when reporter in [:report_current_position, :report_encoder_position_scaled] do
-    {tag, {reporter, String.to_float(x), String.to_float(y), String.to_float(z)}}
+     when reporter in @valid_position_reporters
+   do
+     import String, only: [to_float: 1]
+     msg = {reporter, to_float(x), to_float(y), to_float(z)}
+     {tag, msg}
   end
 
   defp do_parse_pos(["X" <> x, "Y" <> y, "Z" <> z, "Q" <> tag], reporter) do
-    {tag, {reporter, String.to_integer(x), String.to_integer(y), String.to_integer(z)}}
+    import String, only: [to_integer: 1]
+    msg = {reporter, to_integer(x), to_integer(y), to_integer(z)}
+    {tag, msg}
   end
 
   defp do_parse_pos(l, _) do

    {:unhandled_gcode, code}
  end

  @spec parse_report_calibration(binary) :: {binary, {:report_calibration, binary, binary}}
  defp parse_report_calibration(r) do
    [axis_and_status | [q]] = String.split(r, " Q")
    <<a::size(8), b::size(8)>> = axis_and_status

  def parse_code("R05" <> _r), do: {nil, :noop}
  def parse_code("R06 " <> r), do: parse_report_calibration(r)
  def parse_code("R07 " <> _), do: {nil, :noop}
  def parse_code("R08 " <> echo),
    do: {:echo, {:echo, String.replace(echo, "\r", "")}}
  def parse_code("R09 " <> tag),  do: {tag, :invalid_command}

  # Report axis homing.
