Updated prototype documentation.
Re-factored implementation to better avoid repetitious code.