Added support for upward detection. New layout and minor improvements.